<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');?>
<?php $this->load->view(TPL_FOLDER."header");?>
<table width="100%" border="0" cellpadding="5" cellspacing="0" >
  <tr>
    <td width="3%" align="left" ><img src="{tpl_path}images/forward.jpg" /></td>
    <td width="97%" align="left" >您现在的位置：<a href="<?php echo site_url(CTL_FOLDER."ads");?>">全部广告</a> </td>
  </tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0" style="border-bottom:solid 1px #3C4952; margin-bottom:5px; margin-top:5px">
  <tr>
    <td height="24" align="center" ><span style="cursor:pointer" onClick="RqData()"><img src="{tpl_path}images/add.png"> 添加广告</span></td>
  </tr>
</table>
<form method="post" name="list_form" id="list_form">
  <table cellspacing="0" class="widefat">
    <thead>
      <tr id="trth">
        <th width="7%"><input type="checkbox" onClick="check_box(this.form.rd_id)" /></th>
        <th width="17%">缩略图</th>
        <th width="35%" id="title">广告标题</th>
        <th width="15%">尺寸（像素）</th>
        <th width="12%">广告类型</th>
        <th width="14%">操作</th>
      </tr>
    </thead>
    <tfoot>
    </tfoot>
    <tbody id="check_box_id">
      <?php foreach($query->result() as $row) {?>
      <tr>
        <td class="rdId"><input name="rd_id[]" type="checkbox" id="rd_id" value="<?php echo $row->id;?>"></td>
        <td><?php 
		if($row->is_pic==1)
		{
			?>
			 <img src="{tpl_path}images/loading.gif" rel="{root_path}<?php echo $row->file_path;?>" border="0" class="jq_pic_loading"  />
		<?php
		}
		else
		{
			echo "无缩略图";
		}
		?>
        </td>
        <td><div class="celltext"><?php echo $row->title;?></div></td>
        <td><?php 
		echo $row->width." X ".$row->height;
		?>
        </td>
        <td><?php 
		if($row->is_pic==1)
		{
		?>
          <img src="{tpl_path}images/icon-viewpic.gif" title="图片广告" border="0">
          <?php 
		}
		else
		{
		?>
          <img src="{tpl_path}images/swf.gif" title="flash广告" border="0">
          <?php
		}
		?>
        </td>
        <td><a href="<?php echo site_url(CTL_FOLDER."ads/edit_record/".$row->id);?>">修改</a></td>
      </tr>
      <?php }?>
    </tbody>
  </table>
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td style="padding-top:5px"><select name="action_url" id="action_url">
          <option value="" style="color:#FF0000">-选择操作-</option>
          <option value="<?php echo site_url(CTL_FOLDER."ads/del_record");?>">删除</option>
        </select>
        &nbsp;
        <input type="button" name="submit_list_button" class="button-style2" onClick="submit_list_form(this.form,this)" id="submit_list_button" value="执行操作" />  <img src="{tpl_path}images/notice.gif" class="tooltips" title="操作步骤：在左边勾选要操作的记录-->选择需要执行的操作-->点击“执行操作”按钮-->完成" />
      </td>
    </tr>
  </table>
</form>
<div id="dialog_add" style="display:none; position:relative">
  <form action="<?php echo site_url(CTL_FOLDER."ads/add_record");?>" method="post" enctype="multipart/form-data" name="dialog_add_form" id="dialog_add_form">
    <table width="100%"  border="0" cellpadding="3" cellspacing="0" >
      <tr>
        <td width="176"><font color="#FF0000">*</font>广告类型：</td>
        <td width="793"><input name="is_pic" type="radio" value="1" checked>
          图片
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          <input type="radio" name="is_pic" value="0">
          Flash </td>
      </tr>
      <tr>
        <td width="176"><font color="#FF0000">*</font>广告图片标题：</td>
        <td width="793"><input Name="title" type="text" Id="title" size="30" dataType="Require" msg="该项必须填写">
        </td>
      </tr>
      <tr>
        <td width="176"><font color="#FF0000">*</font>广告尺寸(像素)：</td>
        <td width="793">宽
          <input name="width" type="text" size="5" dataType="Integer" msg="宽度必须是数字">
          x 高
          <input name="height" type="text" size="5"  dataType="Integer" msg="高度必须是数字">
        </td>
      </tr>
      <tr>
        <td width="176">链接地址：</td>
        <td width="793"><input Name="hplink" type="text" Id="hplink" value="#" size="50" ></td>
      </tr>
      <tr>
        <td>上传文件：</td>
        <td><input type="text" name="pic_path" id="pic_path" size="25" /> <input name="pic" type="file" id="pic" size="15" dataType="Filter" accept="jpg,png,gif,swf" require="false" msg="文件格式必须是：jpg|png|gif|swf" title="上传的文件格式必须是：jpg|png|gif|swf,且单个文件不能超过 <?php echo ini_get("upload_max_filesize");?>">  <input type="button" name="sfbtn" class="button-style2" onclick="GetFileDialog('pic_path')" value="选择文件" />
        </td>
      </tr>
    </table>
  </form>
</div>
<script language="javascript">
$(function(){
	$("div.celltext").edit_table({
		param:{'table':'weisu_ads'}
	});
});
function RqData(){
	$('#dialog_add').dialog({  
		hide:'',      
		autoOpen:false,
		width:750,
		height:300, 
		modal:true, //蒙层  
		title:'添加广告图片', 
		close: function(){ 
			document.getElementById("dialog_add_form").reset();
			//$(this).dialog('destroy');
		},  
		overlay: {  
			opacity: 0.5, 
			background: "black"
		},  
		buttons:{  
			'取消':function(){$(this).dialog("close");},
			'添加广告图片':function(){dialog_add();}  
		}
	});
	$('#dialog_add').dialog('open');
}	

function dialog_add(){
	var form_ob=document.getElementById("dialog_add_form"); 
	if (!Validator.Validate(form_ob,3)) return false;
	form_ob.submit();
}

</script>
<?php $this->load->view(TPL_FOLDER."footer");?>